#pragma once

namespace catan
{
	class RefCounter
	{
	public:
		unsigned int AddRef()
		{
			return ++mUseCount;
		}
		unsigned int ReleaseRef()
		{
			if (--mUseCount)
			{
				return mUseCount;				
			}
			else
			{
				delete this;		
				return 0;
			}
		}
	protected:
		RefCounter(void)
			: mUseCount(0)
		{
			AddRef();
		}
		virtual ~RefCounter(void){}
		unsigned int mUseCount;
	};
}	